//
//  CustomCellTableViewCell.m
//  moon
//
//  Created by beyself on 16/7/28.
//  Copyright © 2016年 beyself. All rights reserved.
//

#import "CustomCellTableViewCell.h"
#import "Utils.h"

@implementation CustomCellTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self  = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    self.backgroundColor = BG;
    
    UIView* subview = [[UIView alloc] init];
    subview.frame = CGRectMake(10, 0, SCREEN_WIDTH - 20, 0);
    subview.tag = 2100;
    subview.layer.cornerRadius = 5;
    subview.layer.masksToBounds = YES;
    subview.backgroundColor = WHITE;
    [self addSubview:subview];
    
    UIButton* imageview = [UIButton buttonWithType:UIButtonTypeCustom];
    imageview.frame = CGRectMake(10, 10, 44, 44);
    imageview.contentMode = UIViewContentModeScaleAspectFill;
    imageview.layer.cornerRadius = 22;
    imageview.layer.masksToBounds = YES;
    imageview.tag = 2101;
    [imageview addTarget:self action:@selector(iconClick:) forControlEvents:UIControlEventTouchUpInside];
    [subview addSubview:imageview];
    
    UILabel* label = [[UILabel alloc] init];
    label.frame = CGRectMake(64, 10, 240, 20);
    label.font = FONT_15;
    label.textColor = BLUE;
    label.tag = 2102;
    [subview addSubview:label];
    
    UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(SCREEN_WIDTH - 45, 15, 40, 20);
    btn.tag = 2200;
    btn.enabled = NO;
    btn.titleEdgeInsets = UIEdgeInsetsMake(-5, 0, 0, 0);
    btn.titleLabel.font = FONT_10;
    [btn setTitleColor:WHITE forState:UIControlStateDisabled];
    [btn setBackgroundImage:[UIImage imageNamed:@"label_s"] forState:UIControlStateDisabled];
    [self addSubview:btn];
    
    label = [[UILabel alloc] init];
    label.frame = CGRectMake(64, 30, 240, 20);
    label.font = FONT_13;
    label.textColor = ORANGE;
    label.tag = 2103;
    [subview addSubview:label];
    
    label = [[UILabel alloc] init];
    label.frame = CGRectMake(64, 60, 240, 20);
    label.font = FONT_14;
    label.textColor = BLACK;
    label.tag = 2104;
    label.numberOfLines = 0;
    label.lineBreakMode = NSLineBreakByCharWrapping;
    [subview addSubview:label];
    
    for(int i = 0; i < 9; i++)
    {
        UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.tag = 2105 + i;
        button.layer.masksToBounds = YES;
        [button addTarget:self action:@selector(imageviewClick:) forControlEvents:UIControlEventTouchUpInside];
        button.contentMode = UIViewContentModeScaleAspectFill;
        
        UIImageView* icon = [[UIImageView alloc] init];
        icon.tag = 1234;
        icon.contentMode =  UIViewContentModeScaleAspectFill ;
        [button addSubview:icon];
        
        [subview addSubview:button];
    }
    
    label = [[UILabel alloc] init];
    label.frame = CGRectMake(64, 60, 240, 20);
    label.font = FONT_12;
    label.textColor = LINE;
    label.tag = 2114;
    [subview addSubview:label];
    
    for(int i = 0; i < 2; i++)
    {
        UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.tag = 2115 + i;
        button.titleLabel.font = FONT_12;
        [button setBackgroundImage:[Utils imageFromColor:LINE] forState:UIControlStateNormal];
        [button setTitleColor:WHITE forState:UIControlStateNormal];
        if(i == 0) [button setTitle:@"赞" forState:UIControlStateNormal];
        if(i == 1) [button setTitle:@"评论" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(commandClick:) forControlEvents:UIControlEventTouchUpInside];
        [subview addSubview:button];
    }
    
    UIImageView* imagev = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow"]];
    imagev.tag = 2117;
    [subview addSubview:imagev];
    
    UIView* top = [[UIView alloc] init];
    top.tag = 2118;
    top.backgroundColor = kUIColorFromRGB(0xc8d8e8);
    [subview addSubview:top];
    
    imagev = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_like"]];
    imagev.tag = 2119;
    imagev.frame = CGRectMake(5, 7, 19, 19);
    [top addSubview:imagev];
    
    label = [[UILabel alloc] init];
    label.tag = 2120;
    label.textColor = GRAY;
    label.numberOfLines = 0;
    label.lineBreakMode = NSLineBreakByCharWrapping;
    label.font = FONT_12;
    [top addSubview:label];
    
    top = [[UIView alloc] init];
    top.tag = 2121;
    top.backgroundColor = kUIColorFromRGB(0xc8d8e8);
    [subview addSubview:top];
    
    label = [[UILabel alloc] init];
    label.tag = 2122;
    label.textColor = GRAY;
    label.numberOfLines = 0;
    label.lineBreakMode = NSLineBreakByCharWrapping;
    label.font = FONT_12;
    [top addSubview:label];
    
    return self;
}

@end
